﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using System.Web.SessionState;
using DTcms.Web.UI;
using DTcms.Common;

namespace DTcms.Web.m
{
    /// <summary>
    /// slide_company_index 的摘要说明
    /// </summary>
    public class slide_company_index : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            int _company_id = DTRequest.GetQueryInt("company_id");
            StringBuilder strTxt = new StringBuilder();
            strTxt.Append("{");
            //获取公司简介等
            BLL.company bll3 = new BLL.company();
            Model.company model = bll3.GetModel(_company_id);
            ///#### 企业黄页 banner修改  单幅图片为最多三幅，轮播
            ///#### Demon 2018-10-29
            BLL.company_albums bllcomb = new BLL.company_albums();
            DataSet ds1  = bllcomb.GetList(" company_id=" + _company_id);
            if (ds1.Tables[0].Rows.Count > 0)
            {
                
                strTxt.Append("\"top_pic_list\":[");
               
                for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
                {
                    DataRow dr = ds1.Tables[0].Rows[i];

                    strTxt.Append("{\"picurl\":\"" + dr["original_path"].ToString() + "\"}");


                    //是否加逗号
                    if (i < ds1.Tables[0].Rows.Count-1)
                    {
                        strTxt.Append(",");
                    }
                }
                strTxt.Append("]");

            }
            else
            {
                
                if (!string.IsNullOrEmpty(model.topimg))
                {
                    strTxt.Append("\"top_pic_list\":[");
                    strTxt.Append("{\"picurl\":\"http://pic.shicaiquanzi.com" + model.topimg + "\"}");
                    strTxt.Append("]");
                }
                else
                {
                    strTxt.Append("\"top_pic_list\":[]");
                }
                
                //strTxt.Append("\"top_pic_list\":[]");
            }

            strTxt.Append("}");
            context.Response.Write(strTxt.ToString());
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}